import {createApp} from 'vue'
import App from './App.vue'
import router from './router'
import '@/assets/base.css'
import pinia from "@/store/pinia";

// 引入ElementPlus 相关
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 中文
import locale from 'element-plus/lib/locale/lang/zh-cn'

// 引入Axios 工具类的请求对象
import request from "@/utils/AxiosUtils";

// 引入markdown 编辑器
import VMdEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
// 内容定位的插件，可以使内容居中对齐
import createAlignPlugin from '@kangc/v-md-editor/lib/plugins/align';
// 代码行号插件
import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';

// 引入markdown 预览器
import VMdPreview from '@kangc/v-md-editor/lib/preview';
import '@kangc/v-md-editor/lib/style/preview.css';

// vuepressTheme 主题
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';


// 代码高亮
import Prism from 'prismjs';
// 安装 字节跳动的 IconPark Icons
import {install} from '@icon-park/vue-next/es/all';


// markdown编辑器使用代码高亮
VMdEditor.use(vuepressTheme, {
    Prism,
    // 扩展展示的代码类型，vue 以html格式高亮
    codeHighlightExtensionMap: {
        vue: 'html',
    },
});
// 使用内容定位插件
VMdEditor.use(createAlignPlugin());
// 使用代码行插件
VMdEditor.use(createLineNumbertPlugin());

// markdown预览器使用代码高亮
VMdPreview.use(vuepressTheme, {
    Prism,
    // 扩展展示的代码类型，vue 以html格式高亮
    codeHighlightExtensionMap: {
        vue: 'html',
    },
});
// 使用内容定位插件
VMdPreview.use(createAlignPlugin());
// 使用代码行好插件
VMdPreview.use(createLineNumbertPlugin());


const app = createApp(App)

// 在全局使用 this.$http 即可使用axios对象
app.config.globalProperties.$http = request

// 全局注册ElementPlus icon
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// install(app); // use default prefix 'icon', eg: icon is People, name is icon-people.
// install(app, 'i'); // use custom prefix 'i', eg: icon is People, name is i-people.
install(app);

app.use(router)
app.use(pinia)
app.use(ElementPlus, {locale})
app.use(VMdEditor)
app.use(VMdPreview)

app.mount('#app')
